import request from '@/utils/request'
import type { PageDto, PagesDto, PageReqDto } from '../types'
import type { InsuranceCompanyDto, InsureCompanyDetailDto, InsureCompanyListDto } from './types'

export function getInsCompany(params: PageReqDto & {
    name:string
}):Promise<InsuranceCompanyDto[]>{
    return request.get('/crm-prod-v2/web/pc/crm/insureCompany/list', {
        params
    })
}


// 获取保险公司规则列表
export function getInsCompanyRule(): Promise<{key:string,value:number}[]>{
    return request.get('/crm-prod-v2/web/pc/crm/insureCompanyRule/getKeyValueList')
}


// 获取渠道保司列表 
export function getInsCompanyChannel(): Promise<any>{
    return request.get('/crm-prod-v2/web/insureChannel/list')
}

/**
 * 获取保司列表
 * @returns 
 */
export function getInsureCompanyInfoList(): Promise<{
    id: number,
    name: string,
    code: string
}[]>{
    return request.get('/crm-prod-v2/web/pc/crm/insureCompany/getInsureCompanyInfoList')
}

/**
 * 新增保司
 * @param data 
 * @returns 
 */
export function addInsureCompany(data: InsuranceCompanyDto):Promise<void>{
    return request.post('/crm-prod-v2/web/pc/crm/insureCompany/add', data)
}

/**
 * 编辑保司
 * @param data 
 * @returns 
 */
export function editInsureCompany(data: InsuranceCompanyDto):Promise<void>{
    return request.post('/crm-prod-v2/web/pc/crm/insureCompany/edit', data)
}

/**
 * 查看保司详情
 * @param params 
 * @returns 
 */
export function insureCompanyDetail(params: {
    id: number
}):Promise<InsureCompanyDetailDto>{
    return request.get('/crm-prod-v2/web/pc/crm/insureCompany/detail', {
        params
    })
}

/**
 * 获取保司列表
 * @returns 
 */
export function getInsureCompanyList():Promise<{
    key: string,
    value: number
}[]>{
    return request.get('/crm-prod-v2/web/pc/crm/insureCompany/getKeyValueList')
}
